﻿<div style="width:100%; display:@display;">
    <div class="page">
        <div @onclick="toggle" id="close">X</div>
        <div style="padding: 10px;">
            <ul>
                <li class="item"><span>编码：</span><input readonly="readonly" @bind="@Value.Id" /></li>
                <li class="item"><span>名称：</span><input @bind="@Value.Name" /></li>
                <li class="item"><span>所属Id：</span><input @bind="@Value.ParentId" /></li>
            </ul>
            <ul>
                <li class="item">
                    <span>是否有子类：</span> 
                    <select @bind="@has_child">
                        <option value="1">true</option>
                        <option value="0">false</option>
                    </select>
                </li>
                <li class="item"><span>分类类型：</span><input @bind="@Value.Type" /></li>
                <li class="item"><span>显示顺序：</span><input @bind="@Value.ShowOrder" /></li>
            </ul>
            <div>
                <label>分类描述：</label>
                    <textarea style="width:100%; min-height:200px;" @bind=@Value.Description></textarea>
                <label>备注：</label>
                    <textarea style="width:100%; min-height:200px;" @bind=@Value.Remark></textarea>
            </div>
            <button @onclick="save">保存</button>
        </div>
    </div>
</div>

@code {
    string display = "none";

    public void toggle()
    {
        display = (display == "none") ? "block" : "none";
    }

    [Parameter]
    public EventCallback OnSave { get; set; }

    [Parameter]
    public Model.Category Value { get; set; }

    int has_child = 0;
    void save()
    {
        Value.HasChild = (has_child == 0) ? false : true;
        if (OnSave.HasDelegate) OnSave.InvokeAsync();
    }
}

